/**
 * @文件名称: RequestFilter.java
 * @类路径:   weibo4j.filter
 * @描述:     TODO
 * @作者:     robin
 * @时间:     2012-3-12 上午09:27:10
 * @版本:     1.0.0
 */
package com.dssrz.weibo4j.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @类功能说明:
 * @类修改者:
 * @修改日期:
 * @修改说明:
 * @作者: robin
 * @创建时间: 2012-3-12 上午09:27:10
 * @版本: 1.0.0
 */

public class RequestFilter implements Filter {

	private static boolean redirectFlag = false;

	private FilterConfig config;

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.Filter#destroy()
	 */
	public void destroy() {

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
	 * javax.servlet.ServletResponse, javax.servlet.FilterChain)
	 */
	public void doFilter(ServletRequest servletRequest,
			ServletResponse servletResponse, FilterChain chain)
			throws IOException, ServletException {

		HttpServletRequest request = (HttpServletRequest) servletRequest;
		HttpServletResponse response = (HttpServletResponse) servletResponse;

		chain.doFilter(request, response);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
	 */
	public void init(FilterConfig config) throws ServletException {
		this.config = config;
	}

	public String getInitParameter(String name) {
		return config.getInitParameter(name);
	}

	public FilterConfig getFitlerConfig() {
		return config;
	}

	/**
	 * @return redirectFlag
	 */
	public static boolean isRedirectFlag() {
		return redirectFlag;
	}

	/**
	 * @param redirectFlag
	 *            redirectFlag
	 */
	public static void setRedirectFlag(boolean redirectFlag) {
		RequestFilter.redirectFlag = redirectFlag;
	}
}
